package cn.tedu._05mvcboot02.common.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult {
    private Integer state;
    private String message;
    private Object data;

    public JsonResult(Object data){
        this.data=data;
    }

    public JsonResult(StatuCode statuCode,Object data) {
        this.state=statuCode.getState();
        this.message=statuCode.getMessage();
        this.data = data;
    }

    public static JsonResult ok(Object data){
        return new JsonResult(StatuCode.OPERATION_SUCCESS,data);
    }
    public static JsonResult ok(){
        return ok(null);
    }
    public static JsonResult fail(Object data){
        return new JsonResult(StatuCode.OPERATION_FAILED,data);
    }
}
